﻿CREATE FUNCTION [dbo].[ParentQnttyForChild]
(
	@ParentGoodsId int,
	@ChildGoodsId int,
	@ChildQntty int
)
RETURNS float
AS
BEGIN
DECLARE @fltResult float

SELECT @fltResult = cast(@ChildQntty as float) * cast(C.RetailPack as float) / cast(P.RetailPack as float)
FROM CA.Goods P, CA.Goods C
WHERE P.Id = @ParentGoodsId AND C.Id = @ChildGoodsId

	RETURN @fltResult

END
